20/04/2022

This Demo

Beginning with Rstudio and git

Start a new package based on a git repo.

Encourages collaboration “out of the box”.

Where to get R packages

# Install some standard spatial packages from CRAN
if (!require("sf", quietly = TRUE))
  install.packages(c("sf", "terra"))

# package from Bioconductor
if (!require("BiocManager", quietly = TRUE))
  install.packages("BiocManager")
BiocManager::install()
BiocManager::install("EBImage")
## Warning: package(s) not installed when version(s) same as current; use `force = TRUE` to
##   re-install: 'EBImage'

# Install development package from github
if (!require("remotes", quietly = TRUE))
  install.packages("remotes")

if (!require("ReLTER", quietly = TRUE))
  remotes::install_github("oggioniale/ReLTER")
## Registered S3 method overwritten by 'ggforce':
##   method           from 
##   scale_type.units units
## 
## 
## ReLTER is specially drafted for the LTER community.
## 
## To contribute to the improvement of this package, join the group of
##     developers (https://github.com/oggioniale/ReLTER).
## 
## If you use this package, please cite as:
## 
## Alessandro Oggioni, Micha Silver, Luigi Ranghetti & Paolo Tagliolato.
##     (2021) oggioniale/ReLTER: ReLTER v1.0.0 (1.0.0). Zenodo.
##     https://doi.org/10.5281/zenodo.5576813
## 
## Type 'citation(package = 'ReLTER')' on how to cite R packages in
##     publications.

Loading packages

After installing, we need to load the packages into this R session.

# Convenient way to load list of packages
pkg_list <- c("sf", "terra", "ReLTER", "tmap")
lapply(pkg_list,require, character.only = TRUE)
## Loading required package: terra
## terra 1.5.21
## Loading required package: tmap
## [[1]]
## [1] TRUE
## 
## [[2]]
## [1] TRUE
## 
## [[3]]
## [1] TRUE
## 
## [[4]]
## [1] TRUE

What is ReLTER

library(ReLTER)
maintainer("ReLTER")
## [1] "The package maintainer Alessandro Oggioni, phD (2020) <oggioniale@gmail.com>"
citation("ReLTER")
## 
## To cite the 'ReLTER' package in publications use:
## 
##   Alessandro Oggioni, Micha Silver, Luigi Ranghetti & Paolo Tagliolato.
##   (2021). oggioniale/ReLTER: ReLTER v1.0.0 (1.0.0). Zenodo.
##   https://doi.org/10.5281/zenodo.5576813
## 
## A BibTeX entry for LaTeX users is
## 
##   @Misc{,
##     title = {oggioniale/ReLTER: ReLTER v1.0.0},
##     author = {Alessandro Oggioni and Micha Silver and Luigi Ranghetti and Paolo Tagliolato},
##     year = {2022},
##     note = {R package version v1.0.0},
##   }

Basic functions

ls("package:ReLTER")
##  [1] "%>%"                            "get_activity_info"             
##  [3] "get_dataset_info"               "get_ilter_envcharacts"         
##  [5] "get_ilter_generalinfo"          "get_ilter_parameters"          
##  [7] "get_ilter_research_topics"      "get_network_envcharacts"       
##  [9] "get_network_parameters"         "get_network_related_resources" 
## [11] "get_network_research_topics"    "get_network_sites"             
## [13] "get_site_info"                  "get_site_ODS"                  
## [15] "get_sos_procedurelist"          "produce_network_points_map"    
## [17] "produce_site_map"               "produce_site_parameters_pie"   
## [19] "produce_site_parameters_waffle" "produce_site_qrcode"           
## [21] "taxon_id_pesi"                  "taxon_id_worms"

Categories

  • site specific functions
  • network functions
  • metadata functions
  • taxonomy functions

Examples

Search for DEIMS ID for a particular site. The function get_ilter_generalinfo allows to search by country name and site name.

For the first example, get the DEIMS ID for Hohe Tauern in Austria

hohe = get_ilter_generalinfo(country_name = "Austria",
                              site_name = "Hohe Tauern")
## 
## ---- The requested page could not be found.
##             Please check the DEIMS ID ----
(hohe_id = hohe$uri)
## [1] "https://deims.org/d6936d5d-e036-4b3d-bf3c-4a8702e82f1b"

Plot a basic map of that site. We use the tmap package for viewing maps.

hohe_polygon <- get_site_info(hohe_id, category = "Boundaries")
tm_basemap() + 
  tm_shape(hohe_polygon) +
  tm_fill(col = "blue", alpha = 0.3)

Retrieve metadata about a site.

This example retrieves metadata from Lock Kinord in Scotland.

loch_kinord <- get_ilter_generalinfo(country_name = "United K",
                              site_name = "Loch Kinord")
(loch_kinord_id = loch_kinord$uri)
## [1] "https://deims.org/9fa171d2-5a24-40d3-9c06-b3f9e9d0f270"
loch_kinord_details <- get_site_info(loch_kinord_id,
                                 c("Contacts", "EnvCharacts", "Parameters"))

print(paste("Site manager:",
            loch_kinord_details$generalInfo.siteManager[[1]]['name'],
            loch_kinord_details$generalInfo.siteManager[[1]]['email']))
## [1] "Site manager: Andrew Sier [Primary ECN contact] arjs@ceh.ac.uk"

print("Metadata contact:")
## [1] "Metadata contact:"
(loch_kinord_details$generalInfo.metadataProvider[[1]]['name'])
##                                name
## 1 Andrew Sier [Primary ECN contact]
## 2                    Caroline Dilks
print(paste("Average air temperature:",
            loch_kinord_details$envCharacteristics.airTemperature.avg))
## [1] "Average air temperature: 6.62"
print(paste("Annual precipitation:",
            loch_kinord_details$envCharacteristics.precipitation.annual))
## [1] "Annual precipitation: 1031.3"
print(paste("GeoBonBiome:",
            loch_kinord_details$envCharacteristics.geoBonBiome[[1]]))
## [1] "GeoBonBiome: Fresh water lakes"
print("Parameters:")
## [1] "Parameters:"
(loch_kinord_details$parameter[[1]]['parameterLabel'])
##                       parameterLabel
## 1                   ammonium content
## 2    benthic invertebrates abundance
## 3     benthic invertebrates presence
## 4                       conductivity
## 5                 dissolved nutrient
## 6  dissolved organic carbon in water
## 7                ecosystem parameter
## 8         inorganic nutrient content
## 9                         lake level
## 10                  lake temperature
## 11                  nitrogen content
## 12                 species abundance
## 13                  species presence
## 14                  suspended solids
## 15              total organic carbon
## 16                     water acidity
## 17                  water alkalinity
## 18                       water level
## 19                   water parameter
## 20                     water quality
## 21                 water temperature
## 22                water transparency

Query a network

The LTER network in Slovakia

lter_slovakia_id = "https://deims.org/networks/3d6a8d72-9f86-4082-ad56-a361b4cdc8a0"

network_research_topics <- get_network_research_topics(lter_slovakia_id)
head(network_research_topics$researchTopicsLabel, 20)
##  [1] "animal ecology"      "biodiversity"        "biology"            
##  [4] "climate change"      "climate monitoring"  "climatology"        
##  [7] "community dynamics"  "community ecology"   "ecology"            
## [10] "ecosystem ecology"   "ecosystem function"  "ecosystem service"  
## [13] "forest ecology"      "history"             "land use history"   
## [16] "meteorology"         "phenology"           "plant ecology"      
## [19] "population dynamics" "population ecology"

network_sites <- get_network_sites(lter_slovakia_id)
network_sites$title
## [1] "Bab - Slovakia"                                            
## [2] "Jalovecka dolina - Slovakia"                               
## [3] "Kremnicke vrchy Ecological Experimental Station - Slovakia"
## [4] "Tatra National Park - Slovakia"                            
## [5] "Polana Biosphere Reserve (Hukavsky grun) - Slovakia"       
## [6] "Tatras - alpine summits - Slovakia"                        
## [7] "Kralova hola - Slovakia"                                   
## [8] "Poloniny National Park LTSER - Slovakia"                   
## [9] "Trnava LTSER - Slovakia"

Show map of sites in the network

lter_slovakia <- produce_network_points_map(lter_slovakia_id, "SVK")
svk <- readRDS("gadm36_SVK_0_sp.rds")  # from running produce_network_points_map()
tm_basemap() + 
  tm_shape(lter_slovakia) + 
  tm_dots(col = "blue", size=0.04) +
  tm_shape(svk) + 
  tm_borders(col = "purple") +
  tm_grid(alpha = 0.4) +
  tm_scale_bar(position = c("right", "bottom"))

Dependency on DEIMS-SDR

ReLTER relies on the data entered into DEIMS-SDR. However there are:

  • Multiple sites with similiar names
  • Missing information
  • Sites with no boundary polygon

First example, the Kiskun region of Hungary

Query for Site Manager

# Multiple sites in the KISKUN region of Hungary
kiskun <- get_ilter_generalinfo(country_name = "Hungary",
                              site_name = "KISKUN")
# How many sites?
print(paste("In Kiskun region: ", length(kiskun$title), "sites"))
## [1] "In Kiskun region:  8 sites"

(kiskun$title)
## [1] "Kiskun Forest Reserve Sites, KISKUN LTER - Hungary"   
## [2] "VULCAN Kiskunsag, KISKUN LTER - Hungary"              
## [3] "Kiskun Restoration Experiments, KISKUN LTER - Hungary"
## [4] "Kiskun Site Network (Jedlik), KISKUN LTER - Hungary"  
## [5] "KISKUN LTER - Hungary"                                
## [6] "LTER Fulophaza Site, KISKUN LTER - Hungary"           
## [7] "Bugac-Bocsa-Orgovany Site, KISKUN LTER - Hungary"     
## [8] "Orgovany Site, KISKUN LTER - Hungary"
# Which site? Bugac-Bocsa
bugac_id <- kiskun[7,]$uri
bugac_details <- get_site_info(bugac_id,"Contacts")
(bugac_details$generalInfo.siteManager[[1]]['name'])
##          name
## 1 Gábor Ónodi

Now query for boundary

bugac_polygon <- get_site_info(bugac_id, "Boundaries")
## 
## ----
## This site does not have boundaries uploaded to DEIMS-SDR.
## Please verify in the site page: https://deims.org/609e5959-8cd8-44a0-ab42-eda521cd452a
## ----
str(bugac_polygon)
## tibble [1 × 9] (S3: tbl_df/tbl/data.frame)
##  $ title       : chr "Bugac-Bocsa-Orgovany Site, KISKUN LTER - Hungary"
##  $ uri         : chr "https://deims.org/609e5959-8cd8-44a0-ab42-eda521cd452a"
##  $ boundaries  : logi NA
##  $ geoCoord    : chr "POINT (19.5281 46.7183)"
##  $ country     :List of 1
##   ..$ : chr "Hungary"
##  $ geoElev.avg : int 112
##  $ geoElev.min : int 105
##  $ geoElev.max : int 120
##  $ geoElev.unit: chr "msl"
# No geometry
  • This site has the site manager’s name
  • but no boundary polygon

Second example, Gran Paradiso in Italy

paradiso <- get_ilter_generalinfo(country_name = "Italy",
                              site_name = "Gran Paradiso")
(paradiso$title)
## [1] "IT23 - Gran Paradiso National Park - Italy"
## [2] "Gran Paradiso National Park - Italy"
# Choose the second
paradiso_id <- paradiso[2,]$uri
paradiso_details <- get_site_info(paradiso_id,"Contacts")
# Multiple names for metadata:
paradiso_details$generalInfo.metadataProvider[[1]]['name']
##                 name
## 1 Alessandro Oggioni
## 2     Ramona Viterbi
# No funding agency
paradiso_details$generalInfo.fundingAgency
## [1] NA
  • This site has metadata providers
  • but no funding agency

Acquiring Earth Observation data

Functions within ReLTER help to acquire certain Earth Observation datasets. The get_site_ODS() function offers to ReLTER users access to the OpenDataScience Europe (ODS) archive (https://maps.opendatascience.eu/) with landcover, NDVI, natura2000 all at 30 meter pixel resolution. Cropping to site boundaries is done in the cloud, and due to the Cloud Optimized Geotiff (COG) format, downloads are quite small.

First example, Kis-Balaton site in Kiskun region, Hungary

# Get DEIMS ID for Kis-Balaton site 
kis_balaton <- get_ilter_generalinfo(country_name = "Hungary",
                              site_name = "Kis-Balaton")
kb_id = kis_balaton$uri
kb_polygon = get_site_info(kb_id, "Boundaries")

# Now acquire landcover and NDVI from OSD
kb_landcover = get_site_ODS(kb_id, dataset = "landcover")
kb_ndvi_summer = get_site_ODS(kb_id, "ndvi_summer")

# Plot maps
tm_basemap() + 
  tm_shape(kb_polygon) +
  tm_borders(col = "purple") + 
  tm_shape(kb_ndvi_summer) +
  tm_raster(alpha=0.7, palette = "RdYlGn")

tm_basemap() + 
  tm_shape(kb_polygon) +
  tm_borders(col = "purple") + 
  tm_shape(kb_landcover) +
  tm_raster(alpha=0.7, palette = "Set1")

Second example, Companhia das Lezírias, Portugal

lezirias <- get_ilter_generalinfo(country_name = "Portugal",
                              site_name = "Companhia")
lezirias_id = lezirias$uri
lezirias_polygon = get_site_info(lezirias_id, "Boundaries")

# Now acquire spring NDVI from OSD
lezirias_ndvi_spring = get_site_ODS(lezirias_id, "ndvi_spring")

# Plot maps
tm_basemap() + 
  tm_shape(lezirias_polygon) +
  tm_borders(col = "purple") + 
  tm_shape(lezirias_ndvi_spring) +
  tm_raster(alpha=0.7, palette = "RdYlGn")
# The function outputs a raster. We can save to Geotiff for use in other GIS
class(lezirias_ndvi_spring)
## [1] "SpatRaster"
## attr(,"package")
## [1] "terra"
writeRaster(x = lezirias_ndvi_spring,
            filename = "lezirias_ndvi_spring.tif",
            overwrite = TRUE)

Additional plotting functions

Environmental parameters

ReLTER has implemented some revealing visualizations of the various parameters collected at LTER sites. One visualization is the pie chart of environmental parameters.

In an example above the DEIMS ID of Kis Balaton (Kiskun LTER) was found. We’ll use that site to show a pie chart of environmental variables collected in that site.

produce_site_parameters_pie(kb_id)
## 
## Warning: Removed 1 rows containing missing values (geom_text).

## # A tibble: 8 × 9
##   parameterGroups            n   freq label   end start middle hjust vjust
##   <chr>                  <int>  <dbl> <chr> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 agricultural parameter     1 0.0208 2%    0.131 0     0.0654     0     0
## 2 atmospheric parameter      1 0.0208 2%    0.262 0.131 0.196      0     0
## 3 biological parameter      16 0.333  33%   2.36  0.262 1.31       0     0
## 4 chemical parameter        16 0.333  33%   4.45  2.36  3.40       1     1
## 5 ecosystem parameter        8 0.167  17%   5.50  4.45  4.97       1     0
## 6 physical parameter         1 0.0208 2%    5.63  5.50  5.56       1     0
## 7 soil parameter             1 0.0208 2%    5.76  5.63  5.69       1     0
## 8 water parameter            4 0.0833 8%    6.28  5.76  6.02       1     0

Similarly, a “waffle” chart can be produced.

produce_site_parameters_waffle(kb_id)
## 

## # A tibble: 8 × 4
##   parameterGroups            n   freq label
##   <chr>                  <int>  <dbl> <chr>
## 1 agricultural parameter     1 0.0208 2%   
## 2 atmospheric parameter      1 0.0208 2%   
## 3 biological parameter      16 0.333  33%  
## 4 chemical parameter        16 0.333  33%  
## 5 ecosystem parameter        8 0.167  17%  
## 6 physical parameter         1 0.0208 2%   
## 7 soil parameter             1 0.0208 2%   
## 8 water parameter            4 0.0833 8%

Research topics, Related resources

List all research topics throughout an LTER network.

List related resources for an LTER network.

We demonstrate with the LTER network in Slovakia. Then filter for “Ecosystem” research.

lter_slovakia_id <- "https://deims.org/networks/3d6a8d72-9f86-4082-ad56-a361b4cdc8a0"
slv_research_topics <- get_network_research_topics(lter_slovakia_id)
ecosystem_items <- grepl(pattern = "ecosystem",
                         slv_research_topics$researchTopicsLabel,
                         fixed = TRUE)
# Here is the filtered list
slv_research_topics[ecosystem_items,]
## # A tibble: 3 × 2
##   researchTopicsLabel researchTopicsUri                          
##   <chr>               <chr>                                      
## 1 ecosystem ecology   http://vocabs.lter-europe.net/EnvThes/21689
## 2 ecosystem function  http://vocabs.lter-europe.net/EnvThes/20519
## 3 ecosystem service   http://vocabs.lter-europe.net/EnvThes/20520

List related resources

get_network_related_resources(lter_slovakia_id)
## 
## ---- The requested page could not be found.
##             Please check the DEIMS ID ----
## # A tibble: 7 × 3
##   relatedResourcesTitle                                   uri   relatedResource…
##   <chr>                                                   <chr> <chr>           
## 1 Báb_temperature_precipitation_LTER_EU_SK_001_2014-2018  http… 2019-12-20T13:2…
## 2 LTER_Jalovecka dolina temperature 2003-2017             http… 2020-01-07T15:0…
## 3 LTER Jalovecka dolina precipitation 2013-2017           http… 2019-12-20T13:2…
## 4 LTER EES Kremicke vrchy climate                         http… 2019-12-20T13:2…
## 5 <NA>                                                    <NA>  <NA>            
## 6 LTER Polana-Hukavsky_grun temperature precipitation 20… http… 2019-12-20T13:2…
## 7 Climate Kralova hola_LTER_EU_SK_009_2015-2018           http… 2019-12-20T13:2…

Show a chaining of several functions

This example uses the LTER network in Greece. Call the produce_network_points_map() function (requires both DEIMS network ID and the three letter ISO code for the country to be mapped) to get all sites in a country.

lter_greece_id = "https://deims.org/networks/83453a6c-792d-4549-9dbb-c17ced2e0cc3"
lter_greece <- produce_network_points_map(lter_greece_id, "GRC")
grc <- readRDS("gadm36_GRC_0_sp.rds")
tm_basemap("OpenStreetMap.Mapnik") + 
  tm_shape(lter_greece) + 
  tm_dots(col = "blue", size=0.08) +
  tm_shape(grc) + 
  tm_borders(col = "purple", lwd=2) +
  tm_grid(alpha = 0.4) +
  tm_scale_bar(position = c("right", "bottom"))

What can be done with ReLTER outputs

Plotting with other data

Future plans